//import kotlinx.cinterop.*
//import com.huawei.ffrt.*
//
//@OptIn(ExperimentalForeignApi::class)
//class TaskHandle(internal val nativeHandle: ffrt_task_handle_t) {
//    fun close() { ffrt_task_handle_destroy(nativeHandle) }
//}
//
//@OptIn(ExperimentalForeignApi::class)
//class Queue internal constructor(
//    private val queueHandle: ffrt_queue_t
//) {
//    constructor(type: ffrt_queue_type_t, name: String) : this(
//        ffrt_queue_create(type, name, null) ?: error("Queue creation failed")
//    )
//
//    constructor(name: String) : this(
//        ffrt_queue_create(ffrt_queue_type_t.ffrt_queue_serial, name, null) ?: error("Queue creation failed")
//    )
//
//    // 封装 ffrt_queue_submit
//    fun submit(func: () -> Unit) {
//        val f = createFunctionWrapper(func, ffrt_function_kind_t.ffrt_function_kind_queue)
//        ffrt_queue_submit(queueHandle, f, null)
//    }
//
//    // 封装 ffrt_queue_submit_h
//    fun submitWithHandle(func: () -> Unit): TaskHandle {
//        val f = createFunctionWrapper(func, ffrt_function_kind_t.ffrt_function_kind_queue)
//        val handle = ffrt_queue_submit_h(queueHandle, f, null)
//        return TaskHandle(handle ?: error("Queue submit_h failed"))
//    }
//
//    // 封装 ffrt_queue_cancel
//    fun cancel(handle: TaskHandle): Int = ffrt_queue_cancel(handle.nativeHandle)
//
//    // 封装 ffrt_queue_wait
//    fun wait(handle: TaskHandle) = ffrt_queue_wait(handle.nativeHandle)
//
//    fun close() {
//        ffrt_queue_destroy(queueHandle)
//    }
//}